package day11.task;

import java.util.*;

public class Student {
    private String ID;
    private String name;
    private int age;
    private String sex;

    public Student() {
    }

    public Student(String ID, String name, int age, String sex) {
        this.ID = ID;
        this.name = name;
        this.age = age;
        this.sex = sex;
    }

    public String getID() {
        return ID;
    }

    public void setID(String ID) {
        this.ID = ID;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String toString() {
        return ID + " " + name + " " + age + " " + sex;
    }

    @Override
    public boolean equals(Object o) {//重写equals和hashCode ,原因可能地址值相同，内容不同，或hashCode不同，equals相同
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return age == student.age && Objects.equals(ID, student.ID) && Objects.equals(name, student.name) && Objects.equals(sex, student.sex);
    }

    @Override
    public int hashCode() {
        return Objects.hash(ID, name, age, sex);
    }
}

class Main2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        System.out.println();
        ArrayList<Student> list=new ArrayList<>();
        for(int i=0;i<n;i++) {
            Student student = new Student(sc.next(), sc.next(), sc.nextInt(), sc.next());
            if (!list.contains(student)) {//如果数组中已经有改字符串已经存在数组中 contains()
                // 方法内部其实使用 equals() 方法来查找元素。如果指定的元素与数组中的元素有匹配到，则该方法返回 true。
                //如果我把两个Student类型的对象来比较  一定判断出来false，原因是每个实例在内存中的位置都不一样
                //判断一下list中是否已经存储该对象值，contains(Object obj) 判断list中是否包含有该对象 重写Student类中的equals()和hashCode()方法
                list.add(student);
            }
        }
//        System.out.println(list);
        System.out.println(list.size());
        for(Student a:list){
            System.out.println(a);
        }
    }
}
